
module dynamic_seg_led_timer (
    input sys_clk,
    input sys_rst,
    
    output reg[19:0]  data,
    output reg[5:0]   points,
    output reg          en
);

parameter SEG_TIMER_100MS_COUNTERS = 26'd5000000;

reg [26:0] period_100ms_counter;
reg        period_100ms_round_flag;

//生成一个100ms的周期信号
always @(posedge sys_clk or negedge sys_rst) begin
    if(!sys_rst) begin
        period_100ms_counter <= 26'd0;
        period_100ms_round_flag <= 1'b0;
    end
    else if (period_100ms_counter < SEG_TIMER_100MS_COUNTERS - 1) begin
        period_100ms_counter <= period_100ms_counter + 1'b1;
        period_100ms_round_flag <= 1'b0;
    end
    else begin
        period_100ms_counter <= 26'd0;
        period_100ms_round_flag <= 1'b1;
    end
        
end



//每100ms，计数显示加1，从0-999999

always @(posedge sys_clk or negedge sys_rst) begin
    if (!sys_rst) begin
        data <= 20'd0;
    end
    else  begin
        points  <= 6'b000000;
        en <= 1'b1;
        if (period_100ms_round_flag) begin
            if (data < 23'd999999)
                data <= data + 1'b1;
            else
                data <= 23'd0;
        end
    end
end

endmodule